package com.starsoft.quant.job;

import java.util.Map;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.starsoft.quant.executor.StrategyExecutor;
import com.starsoft.smdc.service.HolidayService;

public class ModelJob implements Job{
	
	private static Logger logger = LoggerFactory.getLogger(ModelJob.class);

	@Override
	public void execute(JobExecutionContext arg0) throws JobExecutionException {

		
		Map<String, Object> dataMap = arg0.getJobDetail().getJobDataMap();
		Integer acountId = (Integer)dataMap.get("acountId");
		StrategyExecutor executor = (StrategyExecutor)dataMap.get("executor");
		HolidayService holidayService = (HolidayService)dataMap.get("holidayService");

		boolean isTradeTime = holidayService.isTradeTime();
		if(isTradeTime){
			try {
				executor.executor(acountId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			logger.info("not trade time");
		}
	}
	
}
